public class Main{
    public static void main(String args[]) {
        MyThread3 r = new MyThread3();
        Thread t1 = new Thread(r);
        Thread t2 = new Thread(r);
        t1.setName("t1");
        t2.setName("t2");
        t1.start();
        t2.start();
    }

}

class MyThread3 implements Runnable {
    static int max = 0;

    public void run(){
        for(int i = 1; i<=5000;i++)		{
            int tmp=max;
            System.out.println(Thread.currentThread().getName() + " " + ++tmp);
            max=tmp;
        }
        System.out.println(Thread.currentThread().getName()+"="+MyThread3.max);
    }
}


